<template>
  <div>
    <div style="font-size:18px;">提现设置</div>
    <hr>
    <br>
    <div style="margin-bottom: 30px;">
    </div>
    <el-form label-position="right" label-width="200px" :model="formLabelAlign">
      <el-form-item label="店铺类型">
        <template>
          <!-- <el-select v-model="shopId" filterable placeholder="请选择">
            <el-option
              v-for="item in shopOptions"
              :key="item.value"
              :label="item.name"
              :value="item.id">
            </el-option>
          </el-select> -->
          <el-select clearable v-model="shopType"  style="width: 200px;"
          placeholder="请选择" @change="getSetting(shopType)">
              <el-option
              v-for="item in shopTypeOption"
              :key="item.id"
              :disabled="item.disabled"
              :label="item.name"
              :value="item.id">
              </el-option>
          </el-select>
        </template> 
      </el-form-item>

      <el-form-item label="服务费">
        <!-- <el-input v-model="formLabelAlign.name"></el-input> -->
        <template>
          <el-input style="width: 200px;" type="number" v-model="serviceMoney" step="0.00001" :min="0.00001" :max="100"></el-input>
        </template> 
      </el-form-item>
      <!-- <el-form-item label="提现次数(天)">
        <template>
          <el-input-number v-model="num8" controls-position="right" :min="1" :max="100"></el-input-number>
        </template> 
      </el-form-item> -->
      <el-form-item label="单次最小提现金额">
        <template>
          <el-input style="width: 200px;" type="number" v-model="minMoney" :min="0" :max="10000000"></el-input>
        </template> 
      </el-form-item>
      <el-form-item label="单次最大提现金额">
        <template>
          <el-input style="width: 200px;" type="number" v-model="maxMoney" :min="0" :max="10000000"></el-input>
        </template> 
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm()">提交</el-button>
        <el-button @click="resetForm()">重置</el-button>
      </el-form-item>
    </el-form>
    
  </div>
</template>
<script>
    import $ from 'jquery';
    import Vue from 'vue';

  export default {
    data() {
        return {
            shop: null,
            shopType: null,
            serviceMoney: 0,
            minMoney: 0,
            maxMoney: 0,
            labelPosition: 'right',
            formLabelAlign: {
              name: '',
              region: '',
              type: ''
            },
            shopTypeOption: [],
        };
    },
    created() {
      // this.rid = localStorage.getItem('rid');
      // this.school = JSON.parse(localStorage.getItem('school'));
      // this.shop = JSON.parse(localStorage.getItem('shop'));
    },
    mounted(){
      var self=this;
      this.getShopType()
    },
    methods: {
      getShopType() {
        this.myajax("/shopType/list",{},res=>{
          if(res.code==1000){
            this.shopTypeOption = res.data.list;
          }
        })
      },
      handleChange(value) {
        console.log(value);
      },
      submitForm() {
        let _data = {
          id: this.shopType,
          serviceMoney: this.serviceMoney,
          minMoney: this.minMoney,
          maxMoney: this.maxMoney,
        }
        console.log(_data)
        this.myajax("/setAmount/update",_data,res=>{
          if(res.code==1000){
            console.log(res)
            this.$message({
              type: 'success',
              message: '设置成功!',
              duration: 2000
            });
          }
        })
      },
      resetForm() {
        this.shopType = "";
        this.serviceMoney = 0.0005;
        this.minMoney = 0;
        this.maxMoney = 0;
      },
      getSetting() {
        let id = this.shopType
        this.myajax("/setAmount/get/"+id,{},res=>{
          if(res.code==1000){
            // console.log(res)
            this.maxMoney = res.data.maxMoney
            this.minMoney = res.data.minMoney
            this.serviceMoney = res.data.serviceMoney
          }
        })
      }
    }
  };
</script>
<style scoped>
    .input_edit{
        width: 200px;
        float: left;
        margin-right:10px;
    }
    .cell{
        padding: 0 5px !important;
        overflow: auto;
    }
</style>
